﻿{include file="Main/menu" /}
<form method="post">
	<div class="panel admin-panel" style="background: #fff">
		<div class="panel-head">
			<strong>{:lang('currency')['list']}</strong>
		</div>
		<div class="padding border-bottom">
			<script>
			//city 参数和回调
			var uid = '{:input("get.uid")}';
            var pid="{:input('get.pid')}";
            var cid="{:input('get.cid')}";
            var aid="{:input('get.aid')}";
            var cateid="{:input('get.cateid')}";
            var selectc = true;
            var selecta = true;
            function select_p(){
                return false;
            }
            function select_c(){
                return false;
            }
            function select_a(){
                location.href="?pid="+pid+"&cid="+cid+"&aid="+aid+'&cateid='+cateid;
            }
            function select_cate() {
                location.href="?pid="+pid+"&cid="+cid+"&aid="+aid+'&cateid='+cateid;
            }
			</script>
			<input type="button" class="button button-small checkall" name="checkall" checkfor="id" value="{:lang('currency')['all_select']}" />
			<a type="button" class="button button-small border-green" href="javascript:edit('__URL__/edit.html')" />{:lang('currency')['add']}</a>
			<a id="select_del" type="button" class="button button-small border-red" href="#" />{:lang('currency')['del']}</a>
			{:lang('label')['select']}{:lang('currency')['city']}:{include file="public/city" /}
			分类：{include file="public/category" /}
			<a type="button" class="button button border-yellow search" href="#" />标题{:lang('label')['search']}</a>
		</div>
		<table class="am-table am-table-striped am-table-hover table-main">
			<tr>
				<th width="50">{:lang('label')['select']}</th>
				<td width="100">展示图</td>
				<th width="120">{:lang('label')['category']}</th>
				<th width="120">{:lang('label')['title']}</th>
				<th width="50">{:lang('label')['price']}</th>
				<th width="200">介绍</th>
				<!--<th width="100">{:lang('label')['flag']}</th>-->
				<th width="100">{:lang('label')['status']}</th>
				<th width="100">{:lang('label')['handle']}</th>
			</tr>
			{volist name="data" id="service"}
			<tr>
				<td >
					<input type="checkbox" name="id" value="{$service.id}" />
				</td>
				<td style="line-height:40px"><img src="{$service.image1}" width="40" height="40"/></td>
				<td style="line-height:40px">{$service.category}</td>
				<td style="line-height:40px">{$service.title}</td>
				<td style="line-height:40px">{$service.price}</td>
				<td style="line-height:40px">{$service.service}</td>
				<!--<td style="line-height:40px"><a data-id="{$service.id}" data-flag="{$service.flag}" data-flagtime="{if $service.flagtime}{$service.flagtime|date='Y-m-d',###}{/if}" class="flag button border-blue button-little" href="javascript:;">{:lang('label')['flag_'.$service.flag]}{if $service.flagtime} _至_ {$service.flagtime|date="Y-m-d",###}{/if}</a></td>-->
				<td style="line-height:40px">{if $service.status == "0"}<span class="icon-check text-sub">{:lang('currency')['status_1']}</span>{else}<span class="icon-times text-dot">{:lang('currency')['status_2']}</span>{/if}</td>
				<td style="line-height:40px"><a class="button border-blue button-little" href="javascript:edit('__URL__/edit.html?id={$service.id}')">{:lang('currency')['edit']}</a> <a class="button border-red button-little" href="__URL__/del.html?id={$service.id}&page={:input('get.page')}" onclick="if(confirm('{:lang('currency')['del']}?')){return true;}return false;">{:lang('currency')['del']}</a> </td>
			</tr>
			{/volist}
		</table>
		{include file="public/pages" /}
	</div>
</form>
<script>
layer.config({
	extend: 'extend/layer.ext.js'
});
$('#select_del').click(function(){
	var str="";
	$("input:checkbox[name=id]:checked").each(function(){
		str+=$(this).val()+",";
	});
	if(str!=''){
		if(confirm("{:lang('currency')['del']}?")){
		    location.href='{$Request.controller}/del.html?id='+str;
		}
	}
});
function edit(url) {
    layer.open({
        type:2,
        title:'',
        area: ['797px', '800px'],
        content:url
    })
}
$('.flag').click(function(){
	var id = $(this).attr("data-id");
	var oflag = $(this).attr("data-flag");
	var oflagtime = $(this).attr("data-flagtime");
	layer.open({
		title: "{:lang('label')['flag']}",
		content: "<div>{:lang('label')['flag']}: <select id='flag'><option value='0'>{:lang('label')['flag_0']}</option><option value='1'>{:lang('label')['flag_1']}</option><option value='2'>{:lang('label')['flag_2']}</option><option value='3'>{:lang('label')['flag_3']}</option><option value='4'>{:lang('label')['flag_4']}</option></select></div><br/><div>{:lang('label')['time']}: <input id='flagtime' type='date' value='"+oflagtime+"'/></div>",
		yes: function(layero, index){
			var flag = $("#flag").val();
			var flagtime = $("#flagtime").val();
			if(flag == oflag && flagtime == oflagtime){
				layer.close(layero);
			}else{
				if(flag>0 && !flagtime){
					alert("{:lang('label')['time']}{:lang('currency')['required']}");
				}else{
					if(flag <= 0){
						flagtime = "";
					}
					$.get("{:url('admin/__URL__/flag')}?id="+id+"&flag="+flag+"&flagtime="+flagtime,function(data){
						layer.msg(data.msg);
						if(data.code=="success"){
							location.reload();
						}
					});
				}
			}
		},
		success: function(layero, index){
			$("#flag").find("option[value='"+oflag+"']").attr("selected",true);
		}
	});
});
$('.search').click(function(){
	layer.prompt({title:'{:lang('label')['service']}{:lang('label')['search']}'},function(val){
		location.href="{:url('/admin/service')}?title="+val;
	});
});
</script>
{include file="Main/menu_footer" /}